function lodashGet(obj, path, defaultValue) {
  if (typeof path !== 'string' && !Array.isArray(path)) {
    return defaultValue;
  }
  let pathList = []
  if (Array.isArray(path)) {
    pathList = path
  } else {
    pathList = path.replace(/\[/g, '.').replace(/]/g, '').split('.');
  }
  let result = obj
  for (const key of pathList) {
    if (!result) return defaultValue;
    result = result[key];
  }
  return result;
}


const object = { 'a': [{ 'b': { 'c': 3 } }] };

const result1 = lodashGet(object, 'a[0].b.c');
console.log(result1);
const result2 = lodashGet(object, ['a', '0', 'b', 'c']);
console.log(result2);
const result3 = lodashGet(object, 'a.b.c', 'default');
console.log(result3);

